<template>
	<view>
		<view class="head">
			<view class="shop" @click="shopShow = true">
				<view class="shop-l">
					<image src="../../static/my/shop.png" mode=""></image>
					{{currnetShop.name}}·{{currnetShop.distance}}km
				</view>
				<view class="shop-r">
					<u-icon name="arrow-right" size="16"></u-icon>
				</view>
			</view>
			
			<view class="balance-box">
				<view class="balance-l">
					<view class="bal-text-1">账户余额(元)</view>
					<view class="bal-text-2">{{money}}</view>
					<view class="bal-btn" @click="balanceShow = true">立即充值</view>
				</view>
				<view class="balance-r">
					<image src="../../static/my/gold.png" mode=""></image>
				</view>
			</view>
			<view style="height: 100rpx;width: 1rpx;"></view>
		</view>
		
		<view class="detail-list">
			<view class="title">使用明细</view>
			<view class="each" v-for="(item,index) in 3">
				<view class="each-l">
					<view class="name">消费</view>
					<view class="time">2022.07.18 10:00</view>
				</view>
				<view class="each-r">
					-20
				</view>
			</view>
		</view>
		
		
		<u-popup :round="20" :closeable="true" :show="shopShow" mode="bottom" @close="close" @open="open">
			<view class="popup-option">
				<view class="option-title">选择门店</view>
				
				<view class="shopList-box">
					<view @click="currnetShop = item" :class="{'active-shop':currnetShop.id == item.id}" class="each-shop" v-for="(item,index) in shopList">
						{{item.name}}·{{item.distance}}km
					</view>
				</view>
				
				<view class="option-btn" @click="confirmShop">确定</view>
			</view>
		</u-popup>
		
		<u-popup :round="20" :closeable="true" :show="balanceShow" mode="center" @close="close" @open="open">
			<view class="popup-balance">
				<view class="balance-title">充值</view>
				
				<view class="select-shop-box">
					<view style="background: #F7F8FA;
border-radius: 20rpx 20rpx 20rpx 20rpx;padding: 30rpx 32rpx;" @click="toShop">
						<view class="shop-img">
							<image src="../../static/my/shop.png" mode=""></image>
							<u-icon name="arrow-right" size="16"></u-icon>
						</view>
						<view class="shop-title">{{currnetShop.name}}</view>
					</view>
					
					<view class="juli">距您 {{currnetShop.distance}}km</view>
				</view>
				<view class="hint">充值仅限该单店可用，其他门店不通用</view>
				
				<view class="balance-btn">确定</view>
			</view>
		</u-popup>
		
	</view>
</template>

<script>
	import {
		mapActions,
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				shopShow:false,
				balanceShow:false,
				currnetShop:{},
				location:'',
				page:1,
				shopList:[],
				money:''
			}
		},
		onLoad() {
			this.getCity()
		},
		methods: {
			...mapActions(['getLocation']),
			async getCity() {
				if (!this.$store.state.location) {
					await this.getLocation()
				}
				this.location = JSON.parse(JSON.stringify(this.$store.state.location))
				this.getShopList()
			},
			getShopList(){
				this.$api.post('/getStoreList',{
					page:this.page,
					city:this.location.city,
					lat:this.location.lat,
					lng:this.location.lng
				}).then((res) => {
					if(res.data){
						this.shopList = res.data
						this.currnetShop = this.shopList[0]
					}
				}).catch((res) => {});
			},
			toShop() {
				this.$skip('/pages/shopList/shopList?id=' + this.currnetShop.id || 0, {
					selectShop: (data) => {
						this.currnetShop = data;
						console.log('666');
					}
				});
			},
			confirmShop(){
				this.shopShow = false;
			},
			open() {
				// console.log('open');
			},
			close() {
				this.shopShow = false;
				this.balanceShow = false
			}
		}
	}
</script>

<style lang="scss">
	page {
		// background-color: #F7F8FA;
	}
	.head {
		width: 100%;
		background: linear-gradient(to bottom,#E5F6F2,#F5F7FA);
		.shop {
			width: 638rpx;
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			margin: auto;
			padding: 29rpx 24rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.shop-l {
				image {
					width: 32rpx;
					height: 32rpx;
					margin-right: 16rpx;
					vertical-align: middle;
				}
				font-weight: bold;
				font-size: 28rpx;
				color: #1C274C;
				width: 580rpx;
				
			}
			.shop-r {
				
			}
		}
		
		
		.balance-box {
			display: flex;
			justify-content: space-between;
			padding: 0 32rpx;
			margin-top: 48rpx;
			.balance-l {
				.bal-text-1 {
					font-weight: 500;
					font-size: 24rpx;
					color: #A3ABB9;
				}
				.bal-text-2 {
					font-weight: bold;
					font-size: 64rpx;
					color: #203460;
					margin-top: 8rpx;
				}
				.bal-btn {
					width: 168rpx;
					height: 64rpx;
					background: #62CB81;
					border-radius: 16rpx 16rpx 16rpx 16rpx;
					font-weight: 500;
					font-size: 26rpx;
					color: #FFFFFF;
					line-height: 64rpx;
					text-align: center;
					margin-top: 25rpx;
				}
			}
			.balance-r {
				width: 267rpx;
				height: 205rpx;
				image {
					width: 267rpx;
					height: 205rpx;
				}
			}
		}
	}
	
	.detail-list {
		width: 750rpx;
		background: #FFFFFF;
		border-radius: 50rpx 50rpx 0rpx 0rpx;
		position: relative;
		top: -50rpx;
		// margin-top: 40rpx;
		.title {
			font-weight: bold;
			font-size: 30rpx;
			color: #1C274C;
			padding: 32rpx 0 0 32rpx;
		}
		.each {
			width: 622rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 24rpx 32rpx;
			margin: auto;
			background: #F7F8FA;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			margin-top: 24rpx;
			.each-l {
				.name {
					font-weight: bold;
					font-size: 30rpx;
					color: #1C274C;
				}
				.time {
					font-weight: 500;
					font-size: 24rpx;
					color: #A4A9B7;
					margin-top: 8rpx;
				}
			}
			.each-r {
				font-weight: bold;
				font-size: 36rpx;
				color: #1C274C;
			}
		}
	}
	
	
	.popup-option {
		padding: 40rpx 32rpx;
		.option-title {
			font-weight: 800;
			font-size: 36rpx;
			color: #1c274c;
			text-align: center;
		}
		.shopList-box {
			height: 400rpx;
			padding-top: 16rpx;
			overflow-x: hidden;
			overflow-y: scroll;
			
			.each-shop {
				width: 622rpx;
				background: #F7F8FA;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				padding: 32rpx;
				font-weight: bold;
				font-size: 28rpx;
				color: #1C274C;
				margin-top: 24rpx;
				text-align: center;
			}
			.active-shop {
				background-color: #4BC264;
				color: #FFFFFF;
			}
		}
		
		.option-btn {
			width: 686rpx;
			height: 106rpx;
			background: #4bc264;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			font-weight: 800;
			font-size: 34rpx;
			color: #ffffff;
			line-height: 106rpx;
			margin-top: 32rpx;
			text-align: center;
		}
	}
	
	.popup-balance {
		width: 520rpx;
		background: #ffffff;
		border-radius: 48rpx 48rpx 48rpx 48rpx;
		padding: 40rpx;
		
		.balance-title {
			font-weight: 800;
			font-size: 36rpx;
			color: #1c274c;
			text-align: center;
		}
		
		.select-shop-box {
			width: 520rpx;
			background: #EAEBEE;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			margin-top: 32rpx;
			// padding: 30rpx 32rpx;
			
			.shop-img {
				display: flex;
				justify-content: space-between;
				image {
					width: 28rpx;
					height: 28rpx;
				}
			}
			.shop-title {
				font-weight: bold;
				font-size: 28rpx;
				color: #1C274C;
				padding: 26rpx 0 0 0;
			}
			
			.juli {
				font-weight: 500;
				font-size: 22rpx;
				color: #6B738B;
				line-height: 26rpx;
				padding: 16rpx 32rpx;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				background-color: #EAEBEE;
			}
		}
		.hint {
			font-weight: 500;
			font-size: 22rpx;
			color: #6B738B;
			line-height: 26rpx;
			margin-top: 54rpx;
			text-align: center;
		}
		
		.balance-btn {
			width: 520rpx;
			height: 90rpx;
			background: #4bc264;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			font-weight: bold;
			font-size: 28rpx;
			color: #ffffff;
			line-height: 90rpx;
			text-align: center;
			margin-top: 32rpx;
		}
	}
</style>
